package nc.impl.dm.m4804.rule;

import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.dm.enumeration.FstatusFlag;
import nc.vo.dm.m4804.entity.DelivBillAggVO;
import nc.vo.dm.m4804.entity.DelivBillHVO;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pubapp.pattern.data.ValueUtils;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;



public class CheckStateRuleForDelete implements IRule<DelivBillAggVO> {
  public void process(DelivBillAggVO[] vos) {
    try {
      for (DelivBillAggVO vo : vos) {
        DelivBillHVO hvo = vo.getParentVO();
        int flag = hvo.getFstatusflag().intValue();

        if (ValueUtils.getInt(FstatusFlag.FREE.value()) != flag)
          ExceptionUtils.wrappBusinessException(
              NCLangRes4VoTransl.getNCLangRes().getStrByID("4014001_0", "04014001-0340")); 



        if (hvo.getCdelivbill_hid() != null) {
          UFBoolean bmissionbillflag = hvo.getBmissionbillflag();
          boolean result = false;
          if (bmissionbillflag != null && bmissionbillflag
            .equals(UFBoolean.TRUE))
            result = true; 

          if (result)
            ExceptionUtils.wrappBusinessException(
                NCLangRes4VoTransl.getNCLangRes().getStrByID("4014001_0", "04014001-0080")); 


        } 
        if (hvo.getBapsettledflag().equals(UFBoolean.TRUE)) {
          String msg = NCLangRes4VoTransl.getNCLangRes().getStrByID("4014001_0", "04014001-0372", null, new String[] { hvo

                
                .getVbillcode() });



          ExceptionUtils.wrappBusinessException(msg);

        } 
      } 
    } catch (Exception e) {
      ExceptionUtils.wrappException(e);
    } 
  }
}
